programming4us
           
 
 
Windows Phone

Programming Windows Phone 7 : Points and Pixels

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
12/27/2010 9:27:00 AM
Another property of the TextBlock that you can easily change is FontSize:
FontSize="36"

But what exactly does this mean?

All dimensions in Silverlight are in units of pixels, and the FontSize is no exception. When you specify 36, you get a font that from the top of its ascenders to the bottom of its descenders measures approximately 36 pixels.

But fonts are never this simple. The resultant TextBlock will actually have a height more like 48 pixels—about 33% higher than the FontSize would imply. This additional space (called leading) prevents successive lines of text from jamming against each other.

Traditionally, font sizes are expressed in units of points. In classical typography, a point is very close to 1/72nd inch but in digital typography the point is often assumed to be exactly 1/72nd inch. A font with a size of 72 points measures approximately an inch from the top of its characters to the bottom. (I say “approximately” because the point size indicates a typographic design height, and it’s really the creator of the font who determines exactly how large the characters of a 72-point font should be.)

How do you convert between pixels and points? Obviously you can’t except for a particular output device. On a 600 dots-per-inch (DPI) printer, for example, the 72-point font will be 600 pixels tall.

Desktop video displays in common use today usually have a resolution somewhere in the region of 100 DPI. For example, consider a 21″ monitor that displays 1600 pixels horizontally and 1200 pixels vertically. That’s 2000 pixels diagonally, which divided by 21″ is about 95 DPI.

By default, Microsoft Windows assumes that video displays have a resolution of 96 DPI. Under that assumption, font sizes and pixels are related by the following formulas:

points = ¾ x pixels

pixels = 4/3 x points

Although this relationship applies only to common video displays, people so much enjoy having these conversion formulas, they show up in Windows Phone 7 programming as well.

So, when you set a FontSize property such as

FontSize="36"

you can also claim to be setting a 27-point font.

For a particular point size, increase by 33% to get a pixel size. This is what you set to the FontSize property of TextBlock. The resultant TextBlock will then be another 33% taller than the FontSize setting.

The issue of font size becomes more complex when dealing with high-resolution screens found on devices such as Windows Phone 7. The 480 x 800 pixel display has a diagonal of 933 pixels. The phone I used for this book has a screen with about 3½″ for a pixel density closer to 264 DPI. (Screen resolution is usually expressed as a multiple of 24.) Roughly that’s 2½ times the resolution of conventional video displays.

This doesn’t necessarily mean that all the font sizes used on a conventional screen need to be increased by 2½ times on the phone. The higher resolution of the phone—and the closer viewing distance common with phones—allows smaller font sizes to be more readable.

When running in a Web browser, the default Silverlight FontSize is 11 pixels, corresponding to a font size of 8.25 points, which is fine for a desktop video display but a little too small for the phone. For that reason, Silverlight for Windows Phone defines a collection of common font sizes that you can use. (I’ll describe how these work in Chapter 7.) The standard MainPage.xaml file includes the following attribute in the root element:

FontSize="{StaticResource PhoneFontSizeNormal}"

This FontSize is inherited through the visual tree and applies to all TextBlock elements that don’t set their own FontSize properties. It has a value of 20 pixels—almost double the default Silverlight FontSize on the desktop. Using the standard formulas, this 20-pixel FontSize corresponds to 15 points, but as actually displayed on the phone, it’s about 2/5 the size that a 15-point font would appear in printed text.

The actual height of the TextBlock displaying text with this font is about 33% more than the FontSize, in this case about 27 pixels.

Other -----------------
- Windows Phone 7 : Changing Caller ID Settings
- Windows Phone 7 : Forwarding Calls
- Windows Phone 7 : Checking Voicemail
- Windows Phone 7 : Making Conference Calls
- Programming Windows Phone 7 : Color Themes
- Programming Windows Phone 7 : The Standard Silverlight Files
- Programming Windows Phone 7 : A First Silverlight Phone Program
- Programming Windows Phone 7 : Sensors and Services
- Programming Windows Phone 7 : The Hardware Chassis
- Windows Phone 7 : Deleting Music or Video
- Windows Phone 7 : Pinning Favorites to Start
- Windows Phone 7 : Listening to FM Radio
- Windows Phone 7 : Playing Podcasts
- Windows Phone 7 : Watching Videos
- Windows Phone 7 : Controlling Music Playback
- Windows Phone 7 : Playing Music
- Windows Phone 7 : Pinning a Favorite Place to Start
- Windows Phone 7 : Adding a Pushpin
- Windows Phone 7 : Changing Map Views
- Windows Phone 7 : Sharing an Address with Someone
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us